package com.greencloud.gcstaffmanagement.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greencloud.framework.springboot.web.ApiResponse;
import com.greencloud.gcstaffmanagement.dto.QueryEmployeeListParamDTO;
import com.greencloud.gcstaffmanagement.mapper.EmployeeDOMapper;
import com.greencloud.gcstaffmanagment.service.IEmployeeService;
import com.greencloud.gcstaffmanagement.model.EmployeeDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/employee")
@RestController
public class StaffController {
    @Autowired
    private EmployeeDOMapper employeeDOMapper;
    @Autowired
    private IEmployeeService employeeService;
    @PostMapping("/page")
    public ApiResponse<List<EmployeeDO>> pager(@RequestBody QueryEmployeeListParamDTO queryEmployeeListParamDTO){
        return ApiResponse.getSuccResponse(employeeService.pager(queryEmployeeListParamDTO));
    }
    @PostMapping("/save")
    public ApiResponse save(@RequestBody EmployeeDO employee){
        System.out.println(employee);
        return ApiResponse.getSuccResponse(employeeService.save(employee));
    }

    @GetMapping("/test")
    public void test1(){
        System.out.println(employeeDOMapper.selectList(new QueryWrapper<>()));
    }
}
